﻿using LatoolNet;

namespace NumericalSolution {
  class ROResult2D {

    private int m_rowLength;
    private int m_colLength;
    private Matrix m_mat = null;
    private int m_numberOfControlVolumes;
    private double[,] m_array = null;
    private bool m_isMatrixType;

    public ROResult2D(Matrix mat, int numberOfControlvolumes) {
      m_rowLength = mat.RowNum;
      m_colLength = mat.ColNum;
      m_mat = mat;
      m_numberOfControlVolumes = numberOfControlvolumes;
      m_isMatrixType = true;
    }

    public ROResult2D(double[,] array) {
      m_rowLength = array.GetLength(0);
      m_colLength = array.GetLength(1);
      m_array = array;
      m_isMatrixType = false;
    }

    public double this[int i, int j] {
      get {
        if (m_isMatrixType) {
          return m_mat[j * m_numberOfControlVolumes + i, 0];
        } else {
          return m_array[i, j];
        }
      }
    }

    public int RowLength {
      get { return m_rowLength; }
    }

    public int ColLength {
      get { return m_colLength; }
    }
  }
}
